<template>
  <el-row class="panel-group" :gutter="40">

    <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
      <div class="card-panel clr" @click="handleSetLineChartData('default')">
        <div class="card-panel-icon-wrapper icon-shoppingCard clr">
          <svg-icon icon-class="example" class-name="card-panel-icon" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">本月注册数</div>
          <div>(reg)</div>
          <count-to class="card-panel-num" :startVal="0" :endVal="data.count" :duration="3600"></count-to>
        </div>
      </div>
    </el-col>


    <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
      <div class='card-panel clr' @click="handleSetLineChartData('reg')">
        <div class="card-panel-icon-wrapper icon-people clr">
          <svg-icon icon-class="chart" class-name="card-panel-icon" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">注册数</div>
          <div>(reg)</div>
          <count-to class="card-panel-num" :startVal="0" :endVal="data.regC" :duration="2600"></count-to>
        </div>
      </div>
    </el-col>



    <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
      <div class="card-panel clr" @click="handleSetLineChartData('clickCount')">
        <div class="card-panel-icon-wrapper icon-message clr">
          <svg-icon icon-class="peoples" class-name="card-panel-icon" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">点击数</div>
          <div>(click)</div>
          <count-to class="card-panel-num" :startVal="0" :endVal="data.clickC" :duration="3000"></count-to>
        </div>
      </div>
    </el-col>
    <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
      <div class="card-panel clr" @click="handleSetLineChartData('shareCount')">
        <div class="card-panel-icon-wrapper icon-money clr">
          <svg-icon icon-class="international" class-name="card-panel-icon" />
        </div>
        <div class="card-panel-description">
          <div class="card-panel-text">分享数</div>
          <div>(share)</div>
          <count-to class="card-panel-num" :startVal="0" :endVal="data.shareC" :duration="3200"></count-to>
        </div>
      </div>
    </el-col>

  </el-row>
</template>

<script>
import CountTo from "vue-count-to";

export default {
  components: {
    CountTo
  },
  props: {
    data: {
      type: [Array, Object],
      default: () => ({
        count: 0,
        clickC: 0,
        shareC: 0,
        regC: 0
      })
    }
  },
  methods: {
    handleSetLineChartData(type) {
      this.$emit("handleSetLineChartData", type);
    }
  }
};
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.panel-group {
  margin-top: 18px;
  .card-panel-col {
    margin-bottom: 32px;
  }
  .card-panel {
    _height: 108px;
    cursor: pointer;
    font-size: 12px;
    position: relative;
    _overflow: hidden;
    color: #666;
    background: #fff;
    box-shadow: 4px 4px 40px rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.05);
  }

  .icon-people {
    color: #40c9c6;
  }
  .icon-message {
    color: #36a3f7;
  }
  .icon-money {
    color: #f4516c;
  }
  .icon-shoppingCard {
    color: #34bfa3;
  }

  .card-panel-icon-wrapper {
    float: left;
    _margin: 14px 0 0 14px;
    margin: 14px;
    padding: 16px;
    transition: all 0.38s ease-out;
    border-radius: 6px;
  }
  .card-panel-icon {
    float: left;
    font-size: 48px;
  }
  .card-panel-description {
    float: right;
    font-weight: bold;
    margin: 26px;
    margin-left: 0px;
  }
  .card-panel-text {
    line-height: 18px;
    color: rgba(0, 0, 0, 0.45);
    font-size: 16px;
    margin-bottom: 12px;
  }
  &:hover {
    .card-panel-icon-wrapper {
      color: #fff;
    }
    .icon-people {
      background: #40c9c6;
    }
    .icon-message {
      background: #36a3f7;
    }
    .icon-money {
      background: #f4516c;
    }
    .icon-shoppingCard {
      background: #34bfa3;
    }
  }

  @media only screen and (max-width: 414px) {
    .card-panel {
      padding: 15px 0;
    }
    .card-panel-icon-wrapper {
      float: inherit;
      width: 80px;
      height: 80px;
      margin: 14px auto;
    }
    .card-panel-description {
      width: 95% !important;
      margin: 0 auto;
      text-align: center;
    }
    .card-panel-description span {
      display: inline-table;
    }
  }

  .card-panel-num {
    font-size: 20px;
  }
}

.clr {
  zoom: 1;
}
.clr:after {
  content: "";
  clear: both;
  display: block;
  height: 0;
  overflow: hidden;
  visibility: hidden;
}
</style>